<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8" />
        <title>onresourcetimingbufferfull callback of resource timing</title>
        <script>
            var supportBufferControlInterface = false;
            var count = 0;
            function buffer_full_call_back()
            {
                count++;
            }
            if (performance && performance.setResourceTimingBufferSize)
            {
                supportBufferControlInterface = true;
                performance.setResourceTimingBufferSize(2);
            }
        </script>
        <link rel="author" title="Intel" href="http://www.intel.com/" />
        <link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
        <script src="/webperf/tests/resources/webperftestharness.js"></script>
        <script>
            setup({ explicit_done: true });

            function onload_test()
            {
                test_equals(count, 1, "onresourcetimingbufferfull should have been invoked once buffer is full!");
                done();
            }
        </script>
    </head>
    <body onload="onload_test();">
        <h1>Description</h1>
        <p>This test validates the functionality of onresourcetimingbufferfull in resource timing.</p>
        <script>
            test_namespace();
            if (!supportBufferControlInterface)
                test_true(false, "performance.setResourceTimingBufferSize() interface is supported!");

            if (performance && performance.clearResourceTimings) {
                performance.clearResourceTimings();
                performance.addEventListener("resourcetimingbufferfull", buffer_full_call_back);
                for (var i = 1; i <= 3; i++) {
                    var image = document.createElement("img");
                    image.src = "/webperf/tests/resources/generate_resource.php?type=image&id=" + i;
                }
            }
        </script>
        <div id="log"></div>
    </body>
</html>
